package com.example.generator.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.generator.entity.TableInfoDO;
import com.example.generator.entity.TableInfoPageDTO;
import com.example.generator.service.TableInfoAppService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * com.five.generator.interfaces.controller
 *
 * @author smallNorth_Lee
 * @date 2022/1/12
 */
@AllArgsConstructor
@RestController
@RequestMapping(value = "/table/info")
public class TableInfoController {

    private final TableInfoAppService tableInfoAppService;

    @ApiOperation(value = "表数据分页查询")
    @PostMapping
    public IPage<TableInfoDO> queryTableInfo(@RequestBody TableInfoPageDTO tableInfoPageDTO) {
        return tableInfoAppService.queryTableInfo(tableInfoPageDTO);
    }

    @ApiOperation(value = "生成代码")
    @PostMapping("/create/code")
    public String createCode(@RequestBody Map<String, Object> objectMap) {
        return tableInfoAppService.createCode(objectMap);
    }
}
